From 7d6b9d98d0bdd4e14aedeb7908c28e4b318c8191 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 14 Oct 2025 08:11:51 +0000 Subject: [PATCH] add debian/ directory Support building debian packages Signed-off-by: Felix Fietkau --- .gitignore | 11 ++++++++ CMakeLists.txt | 8 ++++++ debian/control | 52 ++++++++++++++++++++++++++++++++++++ debian/copyright | 19 +++++++++++++ debian/generate-changelog.sh | 15 +++++++++++ debian/libubox-dev.install | 6 +++++ debian/libubox-utils.install | 2 ++ debian/libubox.install | 3 +++ debian/lintian-overrides | 1 + debian/rules | 21 +++++++++++++++ debian/source/format | 1 + 11 files changed, 139 insertions(+) create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/generate-changelog.sh create mode 100644 debian/libubox-dev.install create mode 100644 debian/libubox-utils.install create mode 100644 debian/libubox.install create mode 100644 debian/lintian-overrides create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/.gitignore b/.gitignore index 5ffd235..6f6c8a8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,14 @@ install_manifest.txt jshn *-example tests.* +obj-* +debian/.debhelper/ +debian/debhelper-build-stamp +debian/*.debhelper.log +debian/*.substvars +debian/files +debian/libubox/ +debian/libubox-dev/ +debian/libubox-utils/ +debian/changelog +debian/tmp/ diff --git a/CMakeLists.txt b/CMakeLists.txt index f40eaa6..28a48ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,3 +98,11 @@ IF(ABIVERSION) SET_TARGET_PROPERTIES(json_script PROPERTIES VERSION ${ABIVERSION}) SET_TARGET_PROPERTIES(blobmsg_json PROPERTIES VERSION ${ABIVERSION}) ENDIF() + +ADD_CUSTOM_TARGET(debian + COMMAND ${CMAKE_COMMAND} -E echo "Generating debian/changelog from git..." + COMMAND ${CMAKE_SOURCE_DIR}/debian/generate-changelog.sh + COMMAND dpkg-buildpackage -b -uc -us + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Building Debian package" +) diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b3eb817 --- /dev/null +++ b/debian/control @@ -0,0 +1,52 @@ +Source: libubox +Maintainer: Felix Fietkau +Section: libs +Priority: optional +Standards-Version: 4.5.0 +Rules-Requires-Root: no +Build-Depends: debhelper-compat (= 12), cmake, pkgconf, libjson-c-dev +Homepage: https://git.openwrt.org/project/libubox.git +Vcs-Browser: https://git.openwrt.org/project/libubox.git +Vcs-Git: https://git.openwrt.org/project/libubox.git + +Package: libubox +Architecture: any +Multi-Arch: same +Pre-Depends: ${misc:Pre-Depends} +Depends: ${shlibs:Depends}, ${misc:Depends} +Section: libs +Description: OpenWrt utility library + Libubox is a utility library used by OpenWrt. It provides various data + structures (AVL tree, linked lists, blob format, key-value lists) and + utilities (event loop, socket helpers, base64 encoding, MD5 hashing, + logging) commonly used in OpenWrt. + . + This package contains the shared libraries: libubox, libblobmsg_json, + and libjson_script. + +Package: libubox-dev +Architecture: any +Multi-Arch: same +Depends: libubox (= ${binary:Version}), libc6-dev|libc-dev, libjson-c-dev, ${misc:Depends} +Section: libdevel +Description: Development files for libubox + Libubox is a utility library used by OpenWrt. It provides various data + structures (AVL tree, linked lists, blob format, key-value lists) and + utilities (event loop, socket helpers, base64 encoding, MD5 hashing, + logging) commonly used in OpenWrt. + . + This package contains the development files (headers, static libraries, + and symlinks) for libubox. + +Package: libubox-utils +Architecture: any +Multi-Arch: foreign +Depends: libubox (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Description: Utility programs for libubox + Libubox is a utility library used by OpenWrt. It provides various data + structures (AVL tree, linked lists, blob format, key-value lists) and + utilities (event loop, socket helpers, base64 encoding, MD5 hashing, + logging) commonly used in OpenWrt. + . + This package contains the jshn utility for JSON shell integration and + helper shell scripts. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..0d30672 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,19 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: libubox +Source: https://git.openwrt.org/project/libubox.git + +Files: * +Copyright: 2010- Felix Fietkau +License: ISC + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + . + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/debian/generate-changelog.sh b/debian/generate-changelog.sh new file mode 100755 index 0000000..f302334 --- /dev/null +++ b/debian/generate-changelog.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +cd "$(dirname "$0")/.." + +COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y%m%d' 2>/dev/null || echo '00000000') +COMMIT_HASH=$(git log -1 --format='%h' 2>/dev/null || echo 'unknown') +COMMIT_TIMESTAMP=$(git log -1 --format='%cd' --date=rfc2822 2>/dev/null || date -R) + +cat > debian/changelog < ${COMMIT_TIMESTAMP} +EOF diff --git a/debian/libubox-dev.install b/debian/libubox-dev.install new file mode 100644 index 0000000..4106ed5 --- /dev/null +++ b/debian/libubox-dev.install @@ -0,0 +1,6 @@ +usr/include/libubox +usr/lib/libubox.so +usr/lib/libubox.a +usr/lib/libblobmsg_json.so +usr/lib/libblobmsg_json.a +usr/lib/libjson_script.so diff --git a/debian/libubox-utils.install b/debian/libubox-utils.install new file mode 100644 index 0000000..e803366 --- /dev/null +++ b/debian/libubox-utils.install @@ -0,0 +1,2 @@ +usr/bin/jshn +usr/share/libubox diff --git a/debian/libubox.install b/debian/libubox.install new file mode 100644 index 0000000..216a3a0 --- /dev/null +++ b/debian/libubox.install @@ -0,0 +1,3 @@ +usr/lib/libubox.so.* +usr/lib/libblobmsg_json.so.* +usr/lib/libjson_script.so.* diff --git a/debian/lintian-overrides b/debian/lintian-overrides new file mode 100644 index 0000000..7662288 --- /dev/null +++ b/debian/lintian-overrides @@ -0,0 +1 @@ +no-manual-page diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..4fdb100 --- /dev/null +++ b/debian/rules @@ -0,0 +1,21 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +BUILD_DIR = obj-$(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + +%: + dh $@ --builddirectory=$(BUILD_DIR) + +override_dh_auto_clean: + dh_auto_clean --builddirectory=$(BUILD_DIR) + rm -rf $(BUILD_DIR) + +override_dh_auto_configure: + cmake -S . -B $(BUILD_DIR) \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=None \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DABIVERSION=$(shell dpkg-parsechangelog | sed -rne 's/^Version: 0\.0\.([0-9]+).*$$/\1/p') \ + -DBUILD_LUA=OFF \ + -DBUILD_EXAMPLES=OFF diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) -- 2.30.2